@extends('layout.main')

@section('content')
    @include('layout.error')
    @include('layout.message')
    <div class="col-sm-8 blog-main">
        <form class="form-horizontal" action="/user/{{$user->id}}/setting" method="POST" enctype="multipart/form-data">
            {{csrf_field()}}
            <div class="form-group">
                <label class="col-sm-2 control-label">用户名</label>
                <div class="col-sm-10">
                    <input class="form-control" name="name" type="text" value="{{$user->name}}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">头像</label>
                <div class="col-sm-2">
                    <input class=" file-loading preview_input" type="file" name="avatar">
                    <img class="preview_img" src="{{$user->avatar}}"
                         style="border-radius:50%;width: 100px;height: 100px" alt="">
                </div>
            </div>
            <button type="submit" class="btn btn-default">修改</button>
        </form>
        <br>
    </div>
@endsection
@section('my_js')
    <script>
        setTimeout("$('.alert-success').hide()", 3000);
        $('.preview_input').on('change', function () {
            var file = this.files[0];
            $('.preview_img').attr('src', window.URL.createObjectURL(file));
        })
    </script>
@endsection

